﻿using IBMU2.UODOTNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mvLibrary.Helpers.Utils
{
    public static class UniObjectUtils
    {
        public static UniDynArray GetLastArgument(this UniSubroutine subRoutine)
        {
            return subRoutine.GetArgDynArray(subRoutine.ArgumentsNumber-1);
        }

        public static string GetLastArgumentAsString(this UniSubroutine subRoutine)
        {
            return subRoutine.GetLastArgument().ToString();
        }

        public static bool IsEmpty(this UniDynArray uniObject)
        {
            return uniObject.Dcount() == 0;
        }
        public static bool IsNotEmpty(this UniDynArray uniObject)
        {
            return uniObject.Dcount() != 0;
        }
        
        public static string ExtractAsString(this UniDynArray uniObject, int attributeNumber, int multiValuePosition, int subValuePosition) 
        {
            return uniObject.Extract(attributeNumber, multiValuePosition, subValuePosition).ToString();
        }
        public static string ExtractAsString(this UniDynArray uniObject, int attributeNumber, int multiValuePosition) 
        {
            return uniObject.Extract(attributeNumber, multiValuePosition).ToString();
        }
        public static string ExtractAsString(this UniDynArray uniObject, int attributeNumber) 
        {
            return uniObject.Extract(attributeNumber).ToString();
        }
        public static int ExtractAsInt(this UniDynArray uniObject, int attributeNumber, int multiValuePosition, int subValuePosition)
        {
            return uniObject.Extract(attributeNumber, multiValuePosition, subValuePosition).ToInt();
        }
        public static int ExtractAsInt(this UniDynArray uniObject, int attributeNumber, int multiValuePosition)
        {
            return uniObject.Extract(attributeNumber, multiValuePosition).ToInt();
        }
        public static int ExtractAsInt(this UniDynArray uniObject, int attributeNumber)
        {
            return uniObject.Extract(attributeNumber).ToInt();
        }

    }
}
